/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.jav;


import javax.microedition.midlet.*;
import com.sun.lwuit.*;
import com.sun.lwuit.events.*;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;
import java.io.IOException;

/**
 * @author Javier
 */
public class InvMovilMidlet extends MIDlet {


 private static Form main;

    private Image imgError;
    private static Command cm_salir;
    private static VentanaEspera waiting = null;

    public void startApp() {

      System.out.println("Holaaaa");



      Display.init(this);
      Resources r = null;
      Resources r2 = null;

        try {
            r = Resources.open("/res/Wood.res");
            r2 = Resources.open("/res/r.res");
        } catch (IOException ex) {
            ex.printStackTrace();
        }
      imgError = r2.getImage("cancel.png");

      UIManager.getInstance().setThemeProps(r.getTheme("Cookbook"));
      
          cm_salir = new Command("Salir",r2.getImage("exit.png"))
          {
                public void actionPerformed(ActionEvent evt) {
                    notifyDestroyed();
                }

          };



          Form inicio = new InicoForm();
          Image img = r2.getImage("fondo");
          inicio.setBgImage(img);
          inicio.addCommand(cm_salir);
          inicio.addCommand(new Command("Inicio", r2.getImage("ok.png")){
                public void actionPerformed(ActionEvent evt) {
                    new Thread(new Runnable() {

                    public void run() {
                          waiting = new VentanaEspera("INICIANDO...");
                          waiting.showModeless();
                          main = new Menu();
                          main.addCommand(cm_salir);
                          waiting.dispose();
                          main.show();
                          
                    }
                }).start();

                }

          });
          inicio.show();

    }

    public static Form getMainForm(){
        return main;
    }


    public static void setMainForm(Form main) {
        InvMovilMidlet.main = main;
        InvMovilMidlet.main.addCommand(cm_salir);
    }

        public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }


}
